package com.tsc.interceptor.demo;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chentl
 * @Date: 2025/06/02/上午10:04
 * @Description:
 */
@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ExecutionTimeInterceptor())
                .addPathPatterns("/api/**")        // 拦截/api开头的路径
                .excludePathPatterns("/public/**"); // 排除/public路径
    }
}
